package singletonDemo;
//双检查锁机制
//保证了不需要同步的代码异步执行
public class MyObject3 {
    private volatile static MyObject3 myObject3;
    private MyObject3(){}
    public static MyObject3 getInstance(){
        if(myObject3==null){
            synchronized(MyObject3.class){
                if(myObject3==null){
                    myObject3 = new MyObject3();
                }
            }
        }
        return myObject3;
    }
}
